package main.java.com.web;

import main.java.com.service.CategoryTwoService;
import main.java.com.service.impl.CategoryTwoServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

//删除信息控制层
@WebServlet("/delet")
public class CategoryDeletServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf-8");
        CategoryTwoService categoryService = new CategoryTwoServiceImpl();
        Long id = Long.parseLong(req.getParameter("deleteid"));
        int count = categoryService.deletdish(id);
        if(count>0){
            resp.getWriter().write("1");
        }else {
            resp.getWriter().write("0");
        }
    }
}
